package com.springboot.rookie.controller.system;

import com.springboot.rookie.pojo.SysUserBean;
import com.springboot.rookie.service.SysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 用户信息
 */
@RestController
@RequestMapping("/system/user")
public class SysUserController {
    @Autowired
    SysUserService sysUserService;

    @ResponseBody
    @GetMapping("/userByName")
    public SysUserBean getUserByName(@RequestParam("name") String userName) {
        return sysUserService.getUserByName(userName);
    }

    @ResponseBody
    @GetMapping("/userById")
    public SysUserBean getUserById(@RequestParam("Id") long userId) {
        return sysUserService.getById(userId);
    }

    @ResponseBody
    @PostMapping("/saveUser")
    public SysUserBean getUserById(SysUserBean info) {
        sysUserService.save(info);
        return info;
    }
}
